package com.guigu.controller;

import com.github.pagehelper.PageInfo;
import com.guigu.ProcureService;
import com.guigu.pojo.Businesses;
import com.guigu.pojo.Procure;

import com.guigu.vo.Pojo;
import com.guigu.vo.ProcureVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RequestMapping("procure")
@RestController
public class ProcureController {
    @Autowired
    private ProcureService procureService;
    @RequestMapping("selectAll1/{pageNo}/{pageSize}")
    public Pojo<Procure> selectAll1(@PathVariable int pageNo, @PathVariable int pageSize, @RequestBody ProcureVo vo) {
        System.out.println(vo);
        PageInfo<Procure> procurePageInfo = procureService.selectAll1(vo, pageNo, pageSize);
        Pojo<Procure> pojo = new Pojo<>();
        pojo.setRows(procurePageInfo.getList());
        pojo.setTotal(procurePageInfo.getTotal());
        return pojo;
    }
    @PutMapping("update")
    public String update(@RequestBody Procure procure) {
        boolean b = procureService.updateById(procure);
        if (b)
            return "ok";
        return "no";
    }
    //分页查询
    @RequestMapping("/selectAll")
    public Pojo<Procure> selectAll(Integer pageNum,Integer pageSize,@RequestBody ProcureVo vo){
        System.out.println(vo);
        System.out.println(pageNum);
        System.out.println(pageSize);
        Pojo<Procure> procurePojo = procureService.selectAll(pageNum, pageSize, vo);
        return procurePojo;
    }
}
